package com.gxsf.wechatbook.repo;

import com.gxsf.wechatbook.pojo.ReserList;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author BeijiRonin
 * @version 1.0.0
 * @date 2021/1/18 18:04
 */
public interface ReserListRepository extends JpaRepository<ReserList, Long> {

    List<ReserList> findAllByLibraryId(long libraryId);

    ReserList findLibraryById(long libraryId);

    @Transactional//事务的注解
    @Modifying//增删改必须有这个注解
    @Query(value = "update reser_list set now_people =:#{#reserList.nowPeople} where id =:#{#reserList.id}",nativeQuery = true)
    int update(ReserList reserList);
}
